﻿using System;
using System.Collections.Generic;
using Glue.Internals;
using GlueTests.Builders;
using Xunit;

namespace GlueTests.PropertyFactoryTests
{
    public class When_asking_for_properties_on_a_given_type
    {
        public class ClassWithTwoPropertiesAndOneMethod
        {
            public String Aproperty { get; set; }
            public decimal AnotherProperty { get; set; }
            public void Amethod() {}
        }

        private readonly List<IObjectMember> members;
        private readonly bool prop1found;
        private readonly bool prop2found;
        private readonly bool methodFound;

        public When_asking_for_properties_on_a_given_type()
        {
            var factory = new ObjectMemberFactoryBuilder().Build();
            members = factory.GetObjectMembers(typeof(ClassWithTwoPropertiesAndOneMethod));

            foreach (var member in members)
            {
                if (member.Name == "Aproperty") prop1found = true;
                if (member.Name == "AnotherProperty") prop2found = true;
                if (member.Name == "Amethod") methodFound = true;
            }
        }

        [Fact]
        public void Should_return_properties()
        {
            
            Assert.True(prop1found && prop2found, "Can't find all members");
        }

        [Fact]
        public void Should_not_return_any_Methods()
        {
            Assert.False(methodFound, "Found a method, I shouldn't!");
            
        }
    }
}
